package duc.cm.t2;

import android.graphics.drawable.AnimationDrawable;
import android.view.View;
import android.widget.RelativeLayout;

public class Animal {

	public int x, y, mark, speed;
	public View img;

	public Animal(View img, int x, int y, int mark, int speed) {
		this.x = x;
		this.y = y;
		this.mark = mark;
		this.speed = speed;
		this.img = img;
	}

	public void animation(View img, int ani) {
		if (img != null) {
			img.setVisibility(View.VISIBLE);
			img.setBackgroundResource(ani);
			AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
			frameAnimation.start();
			frameAnimation.setOneShot(true);
			frameAnimation.run();
		}
	}

	public void setlayout(View v, int left, int top, int right, int bottom) {
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
				Math.round(v.getLayoutParams().width), Math.round(v
						.getLayoutParams().height));
		params.setMargins(left, top, right, bottom);
		v.setLayoutParams(params);

	}

	public int getX() {
		return this.x;
	}

	public int getY() {
		return this.y;
	}

	public int getMark() {
		return this.mark;
	}

	public void setX(int x) {
		this.x = x;
	}

	public void setY(int y) {
		this.y = y;
	}

	public void setMark(int mark) {
		this.mark = mark;
	}

	public void setSpeed(int speed) {
		this.speed = speed;
	}
}
